//
//  TSEmpleWithBtnView.m
//  TSHomeFood
//
//  Created by LYH on 2018/10/12.
//  Copyright © 2018年 Toocms. All rights reserved.
//

#import "TSEmptyView.h"

@implementation TSEmptyView

- (id)initWithFrame:(CGRect)frame SetTipsTitle:(NSString *)Tipstitle SetBackImageName:(NSString *)imageName SetBtntitle:(NSString *)btntitle isShow:(BOOL)showClickbtn BtnAction:(ClickBlock)click
{
    self=[super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor =[UIColor whiteColor];;
        self.hidden = YES;
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:btn];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(kScreenWidth, 30));
            make.center.equalTo(self);
        }];
        btn.title = Tipstitle;
        btn.titleFont = 16;
        btn.titleColor = HexColor(@"b2b2b2");
        
        UIImageView* backImage = [[UIImageView alloc] init];
        [self addSubview:backImage];
        [self bringSubviewToFront:backImage];
        [backImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(btn);
            make.bottom.equalTo(btn.mas_top).offset(-30);
            make.width.equalTo(@75);
            make.height.equalTo(@75);
        }];
        backImage.image = [UIImage imageNamed:imageName];
       
        self.clickBtn.hidden = showClickbtn;
        self.clickBtn.title = btntitle;
        self.clickBtn.titleColor = HexColor(@"#FFFFFF");
        self.clickBtn.backgroundColor = HexColor(@"#FC881C");
        self.clickBtn.cornerRadius = 10;
        [self addSubview:self.clickBtn];
        [self.clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(btn.mas_bottom).offset(30);
            make.left.equalTo(self.mas_left).offset(62);
            make.right.equalTo(self.mas_right).offset(-62);
            make.height.mas_equalTo(40);
        }];
        self.Btnblock=click;
            WeakSelf;
        [[_clickBtn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(id x) {
            if (wself.Btnblock) {
                wself.Btnblock();
            }
        }];
    }
    return self;
}
- (UIButton *)clickBtn
{
    if (!_clickBtn) {
        _clickBtn = [[UIButton alloc]init];
    }
    return _clickBtn;
}
@end
